
include("@CMAKE_INSTALL_PREFIX@/lib/cmake/QtWebApp/QtWebAppConfigVersion.cmake")

if (NOT QtWebApp_FIND_COMPONENTS)
	set(QtWebApp_NOT_FOUND_MESSAGE "The QtWebApp package requires at least one component")
	set(QtWebApp_FOUND False)
	return()
endif()

set(_req)
if (QtWebApp_FIND_REQUIRED)
	set(_req REQUIRED)
endif()

# TODO: Qt5Network is not required for all modules
find_package(Qt5 ${_req} COMPONENTS Core Network)
if (NOT ${Qt5_FOUND})
	set(QtWebApp_NOT_FOUND_MESSAGE "Unable to find Qt5")
	set(QtWebApp_FOUND False)
	return()
endif()

set(QtWebApp_LIBRARIES Qt5::Core Qt5::Network)
set(QtWebApp_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include/qtwebapp)

set(_comps Global ${QtWebApp_FIND_COMPONENTS})

foreach(module ${_comps})
	set(_lib "@CMAKE_INSTALL_PREFIX@/lib/libQtWebApp${module}.so.@qtwebapp_MAJOR@")
	if(EXISTS "${_lib}")
		add_library(QtWebApp${module} SHARED IMPORTED)
		set_target_properties(QtWebApp${module} PROPERTIES
				VERSION "@qtwebapp_VERSION@"
				SOVERSION "@qtwebapp_MAJOR@"
				IMPORTED_LOCATION "${_lib}"
			)
		set(QtWebApp_LIBRARIES ${QtWebApp_LIBRARIES} QtWebApp${module})
		if(NOT module EQUAL "Global")
			string(TOLOWER ${module} _lower_module)
			set(QtWebApp_INCLUDE_DIRS ${QtWebApp_INCLUDE_DIRS} @CMAKE_INSTALL_PREFIX@/include/qtwebapp/${_lower_module})
		endif()
	else()
		set(QtWebApp_NOT_FOUND_MESSAGE "Unable to find libQtWebApp${module}.so.@qtwebapp_MAJOR@")
		set(QtWebApp_FOUND False)
		return()
	endif()
endforeach()

mark_as_advanced(QtWebApp_INCLUDE_DIRS QtWebApp_LIBRARIES)
